home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_11_12 / engbert / identity.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-11  |  1.1 KB  |  53 lines

  1. /*                         IDENTITY.C
  2. **
  3. ** Identify the compressed file, read/write header
  4. ** in compressed file.
  5. */
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include "config.h"
  9.  
  10.  
  11. static char *extension = EXTENSION;
  12. static char *magic_header = MAGIC_HEADER;
  13.  
  14.  
  15.  
  16. /****** is_our_extension (char *) ******************/
  17.  
  18. int is_our_extension (char *file_extension) {
  19.     if (!stricmp(extension, file_extension)) return 1;
  20.     else return 0; /* if they differ */
  21. }
  22.  
  23.  
  24. char *return_extension () {
  25.     return extension;
  26. }
  27.  
  28.  
  29. #ifdef COMPRESS
  30. /************ write_file_header ********************/
  31.  
  32. int write_file_header() {
  33.  
  34.     /* Generate the header, i.e. the first 3 bytes
  35.        of compressed file: */
  36.         putchar(magic_header[0]);
  37.         putchar(magic_header[1]);
  38.         if(ferror(stdout))    return WRITE_ERR;
  39.         else return 0;
  40. }   /* write_file_header*/
  41.  
  42. #else COMPRESS
  43.  
  44. /****** input_is_compressed() *****************/
  45.  
  46. int input_is_compressed() {    /* Check magic number */
  47.     if ((getchar()!=(magic_header[0] & 0xFF))
  48.         || (getchar()!=(magic_header[1] & 0xFF)))
  49.         return 0; /*fail */
  50.     else return 1;
  51. }
  52.  
  53. #endif